package 笔试.新凯来;

import java.util.Scanner;

// 100
public class 按指定规则求和 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 5 == 0 || i % 11 == 0 || i % 13 == 0) {
                sum += i;
            }
        }
        System.out.println(sum);
    }
}

